package com.xyht.medicine_management_system.modules.user.controller;


import com.xyht.medicine_management_system.common.annotation.RequestPass;
import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.user.entity.req.MmsRoleReq;
import com.xyht.medicine_management_system.modules.user.entity.req.MmsUserReq;
import com.xyht.medicine_management_system.modules.user.service.MmsRoleService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-11-12
 */
@RestController
@RequestMapping("/role")
@SecretBody
public class MmsRoleController {
    @Resource
    private MmsRoleService mmsRoleService;

    @PostMapping("/add")
    @ApiModelProperty(value = "添加角色")
    public ResponseResult addUser(@RequestBody MmsRoleReq mmsRoleReq) {
        return mmsRoleService.addRole(mmsRoleReq);
    }
    @PostMapping("/delete")
    @ApiModelProperty(value = "删除角色")
    public ResponseResult deleteRole(@RequestBody MmsRoleReq mmsRoleReq) {
        return mmsRoleService.deleteRole(mmsRoleReq);
    }
    @PostMapping("/update")
    @ApiModelProperty(value = "修改角色")
    public ResponseResult updateRole(@RequestBody MmsRoleReq mmsRoleReq) {
        return mmsRoleService.updateRole(mmsRoleReq);
    }
    @GetMapping("/list")
    @ApiModelProperty(value = "角色列表")
    public ResponseResult getUserList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                      @RequestParam(value = "searchStr",required = false) String searchStr) {
        return mmsRoleService.getRoleList(searchStr, pageNum, pageSize);
    }
    @GetMapping("/detail")
    @ApiModelProperty(value = "角色详情")
    public ResponseResult getRoleDetail(@RequestParam(value = "roleId") String roleId) {
        return mmsRoleService.getRoleDetail(roleId);
    }

}

